import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { BookSchema } from './schemas/book.schema';
import { CarSchema } from './schemas/car.schema';
import { CategorySchema } from './schemas/category.schema';
import { OrderSchema } from './schemas/order.schema';
import { UserSchema } from './schemas/user.schema';

const model = MongooseModule.forFeature([
  {
    name: 'Category',
    schema: CategorySchema,
  },
  {
    name: 'Book',
    schema: BookSchema,
  },
  {
    name: 'User',
    schema: UserSchema,
  },
  {
    name: 'Car',
    schema: CarSchema,
  },
  {
    name: 'Order',
    schema: OrderSchema,
  },
]);

@Module({
  imports: [
    MongooseModule.forRoot(
      'mongodb://admin:123456@localhost:27017/bshop?authSource=admin',
    ),
    model,
  ],
  exports: [model],
})
export class DatabaseModule {}
